# 1768. 交替合并字符串
# https://leetcode.cn/problems/merge-strings-alternately/description/

class Solution:
    def mergeAlternately(self, word1: str, word2: str) -> str:
        result = []
        i, j = 0, 0
        
        while i < len(word1) and j < len(word2):
            result.append(word1[i])
            result.append(word2[j])
            i += 1
            j += 1

        # Append any remaining characters from either string
        result.append(word1[i:])
        result.append(word2[j:])
        return ''.join(result)
    